package com.jie.controller;


import com.jie.annotation.OptLog;
import com.jie.entity.ClockPlan;
import com.jie.entity.Video;
import com.jie.response.RespBean;
import com.jie.service.ClockPlanService;
import com.jie.vo.ClockPlanVO;
import com.jie.vo.ConditionVO;
import com.jie.vo.VideoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static com.jie.constants.OptTypeConst.REMOVE;
import static com.jie.constants.OptTypeConst.SAVE;

@RestController
@RequestMapping("/ClockPlan")
@Api(tags = "打卡计划")
public class ClockPlanController {
    @Autowired
    ClockPlanService clockPlanService;

    @OptLog(optType = SAVE)
    @ApiOperation(value = "添加打卡计划")
    @PostMapping("/saveClockPlan")
    public RespBean<?> saveClockPlan(@Valid @RequestBody ClockPlanVO clockPlanVO) {

        clockPlanService.saveClockPlan(clockPlanVO);
        return RespBean.success("添加打卡计划成功");
    }


    @OptLog(optType = REMOVE)
    @ApiOperation(value = "删除打卡计划")
    @DeleteMapping("/deleteClockPlan/{ClockPlanId}")
    public RespBean<?> deleteClockPlan(@PathVariable("ClockPlanId") Integer ClockPlanId) {
        //后续这里会接入文件上传来定义视频地址路径 现在默认
        Integer id = clockPlanService.deleteById(ClockPlanId);
        return RespBean.success("删除成功",id);
    }

    @ApiOperation(value = "根据id查看打卡计划")
    @GetMapping("/admin/getClockPlanById/{clockPlanId}")
    public RespBean<?> getSportVideoById(@PathVariable("clockPlanId") Integer clockPlanId) {
        //根据当前id获取当前视频素材
        ClockPlan clockPlan = clockPlanService.getById(clockPlanId);
        return RespBean.success("ClockPlan",clockPlan);
    }

    @ApiOperation(value = "查看打卡计划")
    @GetMapping("/admin/operation/logs")
    public RespBean<?> listOperationLogs(ConditionVO conditionVO) {
        return RespBean.success("日志接口调用成功",clockPlanService.listClockPlans(conditionVO));
    }
}
